<template>

	<view class="uni-checkbox">
		<uniDataCheckbox mode="list" icon="right" v-model="chooseValue" :localdata="list" @change="handleChange" />
	</view>
</template>

<script setup>
	import {
		defineProps,
		ref,
		defineEmits,
		onMounted
	} from "vue"
	import uniDataCheckbox from "@/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue"
	const emit = defineEmits(['getCheckData'])
	const props = defineProps({
		list: {
			type: Array,
			default: []
		},
		checkedName: {
			type: Number,
			default: ""
		}
	})
	const chooseValue = ref(null)
	onMounted(()=>{
		chooseValue.value=props.checkedName
	})
	function handleChange(event) {
		if (chooseValue.value||chooseValue.value==0) {
			console.log(chooseValue.value,event.detail.data.text)
			emit("getCheckData", event.detail.data.text)
		}

	}
</script>

<style scoped lang="less">
	.uni-checkbox {
		padding: 0 20rpx;
		margin-bottom: 30rpx;
	}
</style>